﻿using System;
using System.Threading;
using NUnit.Framework;

namespace Medianamik.Tests.Selenium.Medianamik.UI.ConfigManagement
{
    [TestFixture]
    [Ignore]
    public class LanguageListTest : BaseSeleniumFixture
    {
        [Test]
        public void TestLanguageManagement()
        {
            mng.LogToMedianamik();
            selenium.Open("/medianamik/configmanagement/LanguageList.aspx");
            selenium.Click("ctl00_ctl00_ContextMenu_ContextMenu_lnkAddLanguage");
            selenium.SelectFrame("addCultureWindow");
            for (int second = 0; ; second++)
            {
                if (second >= 60) Assert.Fail("timeout");
                try
                {
                    if (selenium.IsElementPresent("ctl00_CenterContent_CultureName")) break;
                }
                catch (Exception)
                { }
                Thread.Sleep(1000);
            }
            selenium.Select("ctl00_CenterContent_CultureName", "label=Spanish (Mexico)");
            selenium.Click("ctl00_CenterContent_ContentManagementActive");
            selenium.Click("ctl00_CenterContent_MedianamikActive");
            selenium.Click("ctl00_CenterContent_AddButton");
            selenium.WaitForPageToLoad("30000");

            selenium.SetSpeed("3000");
            selenium.Click("ctl00_ctl00_CenterContent_CenterContent_GridLanguages_ctl00_ctl04_MedianamikActive");
            Assert.AreEqual("", selenium.GetConfirmation());
            selenium.Click("ctl00_ctl00_CenterContent_CenterContent_GridLanguages_ctl00_ctl04_ContentManagementActive");
            Assert.AreEqual("", selenium.GetConfirmation());
            mng.LogOut();

            mng.RestoreDatabaseState();
        }
    }
}